<template>
  <div class="p-2">
    <el-card class="box-card">   
      <template v-slot:header> 
        <div class="clearfix">
          <el-form inline size="small">
              <el-form-item label="合伙人搜索：">
                <el-input
                  v-model="tableFrom.keywords"
                  placeholder="请输入合伙名称"
                  style="width: 270px;padding-right: 20px;"
                  size="small"
                  clearable
                >
                 
                </el-input>
                <el-button type="primary" size="small" @click="getList">查询</el-button>
              </el-form-item>
            </el-form>
        </div>
      </template>    
      <el-table
        v-loading="listLoading"
        :data="tableData.data"
        style="width: 100%"
        size="default"
        :highlight-current-row="true"
        :header-cell-style="{ fontWeight: 'bold' }"
      >
        <!-- <el-table-column type="index"/> -->
        <el-table-column prop="uid" label="合伙人ID" min-width="100"/>
        <el-table-column
          label="合伙人名称"
          prop="name"
          min-width="120"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
          prop="mobile"
          label="合伙人手机号"
          min-width="90"
          align="center"
        />
        <el-table-column
          prop="description"
          label="申请描述"
          min-width="90"
          align="center"
        />
        <el-table-column label="申请状态" min-width="80" align="center">
          <template #default="{row}">
            <span>{{ checkedFilterHandle(row.status)}}</span>
          </template>
        </el-table-column>

        <el-table-column label="申请时间" min-width="120" align="center">
          <template #default="{row}">
            <span>{{ row.createTime}}</span>
          </template>
        </el-table-column>
        <!-- <el-table-column label="审核时间" min-width="120" align="center">
          <template #default="{row}">
            <span>{{ row.updateTime}}</span>
          </template>
        </el-table-column> -->
        <el-table-column label="操作" min-width="120" fixed="right" align="center">
          <template #default="{row}">
            <div>
              <el-button
                v-if="row.status == '0'"
                type="primary"
                size="small"
                @click="onchangePass(row)"
                >通过</el-button
              >
              <el-button
                v-if="row.status =='0'"
                type="danger"
                size="small"
                @click="onchangeNoPass(row)"
                >拒绝</el-button
              >
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="block">
        <el-pagination
          :page-sizes="[20, 40, 60, 80]"
          :page-size="tableFrom.limit"
          :current-page="tableFrom.page"
          layout="total, sizes, prev, pager, next, jumper"
          :total="tableData.total"
          @size-change="handleSizeChange"
          @current-change="pageChange"
        />
      </div>
    </el-card>
  </div>
</template>

<script>
import {
  partnerApplyListApi,
  examinePartnerApplyPassApi,
  examinePartnerApplyNoPassApi
} from '@/api/shopping/partnerApply';


export default {
  name: 'ExaminePartnerApplyList',
  data() {
    return {
      props: {
        children: 'child',
        label: 'name',
        value: 'id',
        emitPath: false,
      },
      listLoading: true,
      tableData: {
        data: [],
        total: 0,
      },
      tableFrom: {
        page: 1,
        limit: 20,
        keywords: ''
      },
      dialogVisible: false,
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    
    //列表
    getList() {
      this.listLoading = true;
      partnerApplyListApi(this.tableFrom)
        .then((res) => {
          this.tableData.data = res.data.list;
          this.tableData.total = res.data.total;
          this.listLoading = false;
        })
        .catch((res) => {
          this.listLoading = false;
        });
    },
    pageChange(page) {
      this.tableFrom.page = page;
      this.getList();
    },
    handleSizeChange(val) {
      this.tableFrom.limit = val;
      this.getList();
    },
    onchangePass(row) {
      examinePartnerApplyPassApi(row.id)
        .then(() => {
          ElMessage.success('审核完成');
          this.getList();
        })
        .catch(() => {
        })
    },
    onchangeNoPass(row) {
      examinePartnerApplyNoPassApi(row.id)
        .then(() => {
          ElMessage.success('审核完成');
          this.getList();
        })
        .catch(() => {
        })
    },
    //0：未审核，1:审核通过，2：审核拒绝
    checkedFilterHandle(value) { 
      if (value == '0') {
        return '待审核'
      } else if (value == '1') {
        return '通过'
      }else if (value == '2') {
        return '拒绝'
      }
    },
  },
};
</script>

<style scoped lang="scss">
@import "../../../assets/styles/styles.scss";
.el-table__body {
  width: 100%;
  table-layout: fixed !important;
}
.demo-table-expand {
  padding-left: 60px;
  :deep( label) {
    width: 82px;
  }
}
.demo-table-expand {
  :deep( .el-form-item__content) {
    width: 77%;
  }
}
.selWidth {
  width: 250px !important;
}
.seachTiele {
  line-height: 30px;
}
.relative {
  position: relative;
}
.card_abs {
  position: absolute;
  padding-bottom: 15px;
  top: 260px;
  right: 40px;
  width: 200px;
  background: #fff;
  z-index: 99999;
  box-shadow: 0px 0px 14px 0px rgba(0, 0, 0, 0.1);
}
.cell_ht {
  height: 50px;
  padding: 15px 20px;
  box-sizing: border-box;
  border-bottom: 1px solid #eeeeee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.check_cell {
  width: 100%;
  padding: 15px 20px 0;
}
.mt-1 {
  margin-top: 6px;
}
:deep(.el-checkbox__input.is-checked + .el-checkbox__label) {
  color: #606266;
}
</style>
